﻿using System;
using System.ComponentModel.DataAnnotations;

namespace IntellectShop.Common
{
	public struct Duration
	{
		public const int DefaultHoursInDay = 8;

		[DisplayNameLocalized("DurationHours")]
		[Required(ErrorMessage = "Duration hours is required")]
		[Range(0, 3000, ErrorMessage = "Invalid course duration hours")]
		public int Hours { get; set; }

		[DisplayNameLocalized("DurationDays")]
		[Required(ErrorMessage = "Duration days is required")]
		[Range(1, 3000, ErrorMessage = "Invalid course duration days")]
		public int Days { get; set; }

		public Duration(int hours, int days) : this()
		{
			Hours = hours;
			Days = days;
		}

		public override string ToString()
		{
			return String.Format(Resources.Resources.DurationFormat, Days, Hours);
		}
	}
}
